#ifndef B2D_GLGRAPHICSDEVICE_H
#define B2D_GLGRAPHICSDEVICE_H

#include "GraphicsDevice.h"
#include "GL/GLTexture.h"
#include "GL/GLShaderProgram.h"
#include "GL/OpenGL.h"

NS_B2D_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////
/// \brief	OpenGL graphics device.
////////////////////////////////////////////////////////////////////////////////////////////////////
class B2D_API GLGraphicsDevice
	: public GraphicsDevice
{
private:
	/// Flag mask for enabled attributes
	uint32 mActiveAttributes;

	GLTextureFactory mTextureFactory;
	GLShaderProgramFactory mShaderProgramFactory;

public:
	GLGraphicsDevice(void);
	virtual ~GLGraphicsDevice(void);
	
	// ::GraphicsDevice members
	void setViewport(int x, int y, size_t w, size_t h);
	RenderTexture* createRenderTexture(size_t texCount);
	VertexBuffer* createVertexBuffer(void);
	IndexBuffer* createIndexBuffer(void);
	void clearFrameBuffers(uint buffers, const Color& color, float depth, ushort stencil);
	void setTextureSlot(TextureUnit::Unit slot, TexturePtr texture);

_internal:
	// ::GraphicsDevice members
	IGraphicContext* _createGraphicsContext(void);
	void _setActiveRenderTarget(const RenderTarget& rt);
	void _render(const RenderOperation& op);

private:
	// ::GraphicsDevice members
	void setActiveShaderProgramImpl(void);
	void setBlendingImpl(void);
};

NS_B2D_END

#endif